/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Model.DAO;

import Model.Pojo.Agents;
import org.hibernate.Session;

/**
 *
 * @author luong
 */
public class ModelDaoLibrarie {
    public static boolean Ajouter(Object obj){
        boolean Resultat=false;
        Session session = Model.Util.HibernateUtil.getSessionFactory().openSession();
        try {            
            session.save(obj);
            session.beginTransaction().commit();
            Resultat=true;
        } catch (Exception e) {
            System.err.print(e.getMessage());
        }
        finally
        {
            session.close();
        }
        return Resultat;
    }
  
    public static boolean Update(Object obj) {
        boolean Resultat=false;
        Session session = Model.Util.HibernateUtil.getSessionFactory().openSession();
        try {                       
            session.update(obj);
            session.beginTransaction().commit();
            Resultat=true;
        } catch (Exception e) {
            System.err.print(e.getMessage());
        }
        finally
        {
            session.close();
        }
        return Resultat;
    }
}
